package com.csit.dao.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import com.csit.dao.CustomerCardDao;
import com.csit.entity.Customer;
import com.csit.entity.CustomerCard;

@Repository
public class CustomerCardDaoImpl extends BaseDaoImpl<CustomerCard, Integer> implements CustomerCardDao {

	public CustomerCard getCustomerCardByCustomer(Customer customer) {
		Assert.notNull(customer, "customer is required");
		Criteria criteria = getSession().createCriteria(CustomerCard.class);
		criteria.add(Restrictions.eq("customer", customer));
		return (CustomerCard) criteria.uniqueResult();
	}

}
